﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;

namespace PrismWpf.ViewModels
{
	public class IndexViewModel : BindableBase,IConfirmNavigationRequest
	{
        public IndexViewModel()
        {

        }

        /**
         * 离开本页面之前，判断是否能进入对应页面
         */ 
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
        {
            if (MessageBox.Show("退出本页面之后所有未保存的数据将删除", "确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {

                continuationCallback(true);
            }
            else {

                continuationCallback(false);
            }


        }

        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            
        }

        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            
        }
    }
}
